package com.jt.controller;

import com.jt.entity.Classs;
import com.jt.entity.Student;
import com.jt.service.ClasssService;
import com.jt.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @Autowired
    private ClasssService classsService;

    @RequestMapping("/queryAll")
    public String queryAll(ModelMap modelMap) {
        List<Student> students = studentService.queryAll();
        modelMap.addAttribute("students", students);
        return "/student/student_list";
    }

    @RequestMapping("/queryById")
    public void queryById(Integer stuid, ModelMap modelMap) {
        System.out.println("-------------");
        Student student1 = studentService.queryById(stuid);
        System.out.println(student1);
    }

    @RequestMapping("/save")
    public  void  save(){
        System.out.println("----------");
    }

    @RequestMapping("/queryAllCla")
    public  String  queryAllCla(ModelMap modelMap){
        List<Classs> classses = classsService.queryAll();
        modelMap.addAttribute("classsses",classses);
        return "student/student_add";
    }
}
